{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'torchsearchsorted'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-1-26a68b7d8fbd>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mimport\u001b[0m \u001b[0mshow\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0meditingapp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      2\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mimportlib\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mreload\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m \u001b[0mreload\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0meditingapp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m \u001b[0minterface\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0meditingapp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mNeRFEditingApp\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmask_no\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'erase'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m128\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnum_canvases\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m9\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mreal_dir\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'chairs_whitened/shape09173_rank00'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m \u001b[0minterface\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbrushsize_textbox\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalue\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m'3'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/Desktop/adobe/style-nerf/nerf/applications/editingapp.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m      6\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mtorchvision\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mtransforms\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      7\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mPIL\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mImage\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 8\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mrendering\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mrender_path\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      9\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mediting_utils\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mload_dataset\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mload_model\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     10\u001b[0m \u001b[0;31m##########################################################################\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/Desktop/adobe/style-nerf/nerf/applications/rendering.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m      8\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      9\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mtorchvision\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 10\u001b[0;31m \u001b[0;32mfrom\u001b[0m \u001b[0mtorchsearchsorted\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0msearchsorted\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     11\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     12\u001b[0m \u001b[0;32mfrom\u001b[0m \u001b[0mmatplotlib\u001b[0m \u001b[0;32mimport\u001b[0m \u001b[0mpyplot\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'torchsearchsorted'"
     ]
    }
   ],
   "source": [
    "import show, editingapp\n",
    "from importlib import reload\n",
    "reload(editingapp)\n",
    "interface = editingapp.NeRFEditingApp(mask_no='erase', size=128, num_canvases=9, real_dir='chairs_whitened/shape09173_rank00')\n",
    "interface.brushsize_textbox.value = '3'\n",
    "interface.change_brushsize()\n",
    "show(interface)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "shape09173_rank00_0.png       shape09173_rank00_5erase.pt\r\n",
      "shape09173_rank00_11.png      shape09173_rank00_5neg.pt\r\n",
      "shape09173_rank00_111.pt      shape09173_rank00_65.png\r\n",
      "shape09173_rank00_11erase.pt  shape09173_rank00_68.png\r\n",
      "shape09173_rank00_11neg.pt    shape09173_rank00_681.pt\r\n",
      "shape09173_rank00_12.png      shape09173_rank00_68erase.pt\r\n",
      "shape09173_rank00_19.png      shape09173_rank00_68neg.pt\r\n",
      "shape09173_rank00_20.png      shape09173_rank00_72.png\r\n",
      "shape09173_rank00_29.png      shape09173_rank00_73.png\r\n",
      "shape09173_rank00_30.png      shape09173_rank00_731.pt\r\n",
      "shape09173_rank00_32.png      shape09173_rank00_73erase.pt\r\n",
      "shape09173_rank00_36.png      shape09173_rank00_73neg.pt\r\n",
      "shape09173_rank00_39.png      shape09173_rank00_74.png\r\n",
      "shape09173_rank00_41.png      shape09173_rank00_76.png\r\n",
      "shape09173_rank00_43.png      shape09173_rank00_78.png\r\n",
      "shape09173_rank00_431.pt      shape09173_rank00_83.png\r\n",
      "shape09173_rank00_43erase.pt  shape09173_rank00_84.png\r\n",
      "shape09173_rank00_43neg.pt    shape09173_rank00_87.png\r\n",
      "shape09173_rank00_45.png      shape09173_rank00_871.pt\r\n",
      "shape09173_rank00_451.pt      shape09173_rank00_87erase.pt\r\n",
      "shape09173_rank00_45erase.pt  shape09173_rank00_87neg.pt\r\n",
      "shape09173_rank00_45neg.pt    shape09173_rank00_89.png\r\n",
      "shape09173_rank00_47.png      shape09173_rank00_9.png\r\n",
      "shape09173_rank00_48.png      shape09173_rank00_90.png\r\n",
      "shape09173_rank00_481.pt      shape09173_rank00_901.pt\r\n",
      "shape09173_rank00_48erase.pt  shape09173_rank00_90erase.pt\r\n",
      "shape09173_rank00_48neg.pt    shape09173_rank00_90neg.pt\r\n",
      "shape09173_rank00_5.png       shape09173_rank00_91.pt\r\n",
      "shape09173_rank00_50.png      shape09173_rank00_92.png\r\n",
      "shape09173_rank00_51.pt       shape09173_rank00_93.png\r\n",
      "shape09173_rank00_52.png      shape09173_rank00_94.png\r\n",
      "shape09173_rank00_55.png      shape09173_rank00_95.png\r\n",
      "shape09173_rank00_56.png      shape09173_rank00_99.png\r\n",
      "shape09173_rank00_58.png      shape09173_rank00_9erase.pt\r\n",
      "shape09173_rank00_59.png      shape09173_rank00_9neg.pt\r\n"
     ]
    }
   ],
   "source": [
    "ls chairs_whitened/shape09173_rank00"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "from renormalize import from_url\n",
    "import torch\n",
    "from torchvision import utils\n",
    "pos = from_url(torch.load('chairs_whitened/shape09173_rank00/shape09173_rank00_45erase.pt'))\n",
    "utils.save_image(pos.unsqueeze(dim=0), 'pos_mask.png')\n",
    "pos = from_url(torch.load('chairs_whitened/shape09173_rank00/shape09173_rank00_48erase.pt'))\n",
    "utils.save_image(pos.unsqueeze(dim=0), 'neg_mask.png')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
